package api

import (
	"gateway/basic/config"
	__ "gateway/basic/proto"
	"gateway/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func DriverRegister(c *gin.Context) {
	var req request.DriverRegisterReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": http.StatusBadRequest,
			"msg":  "参数错误",
		})
		return
	}
	_, err := config.DacheClient.DriverRegister(c, &__.DriverRegisterReq{
		UserId:        int64(req.UserId),
		DriverName:    req.DriverName,
		DriverLicense: req.DriverLicense,
		Idcard:        req.IdCard,
		DriverStatus:  int64(req.DriverStatus),
		DriverImg:     req.DriverImg,
		DrivingImg:    req.DrivingImg,
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": http.StatusBadRequest,
			"msg":  "客户端连接失败",
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": http.StatusOK,
		"msg":  "司机注册成功",
	})
}

func DriverUpdate(c *gin.Context) {
	var req request.UpdateReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": http.StatusBadRequest,
			"msg":  "参数错误",
		})
		return
	}
}
